#pragma once

#include "FCProperties.h"

namespace UIStone
{
	class FCController_Font : public FCPropertyContainer
		<
			Loki::TL::MakeTypelist
			<
				FCPropertyFontColor,
				FCPropertyFontFamily,
				FCPropertyFontSize,
				FCPropertyFontSizeUnit,
				FCPropertyFontItalic,
				FCPropertyFontUnderline,
				FCPropertyFontStrikeOut,
				FCPropertyFontWeight
			>::Result
		>
	{
	public:
		enum FontSizeUnitType
		{
			FONT_SIZE_UNIT_PX			= 0,
			FONT_SIZE_UNIT_PT			= 1
		};

		FCController_Font()
		{
			_defaultValue();
		}

		virtual ~FCController_Font() {}

	public:
		UINT GetTextFormat() const
		{
			static int c_arrayOverflow[] = { DT_NOCLIP, 0, DT_WORD_ELLIPSIS, DT_END_ELLIPSIS, DT_PATH_ELLIPSIS } ;
			static int c_arrayVOverflow[] = { 0, DT_EDITCONTROL } ;
			static int c_arrayValign[] = { DT_VCENTER, DT_TOP, DT_BOTTOM } ;
			static int c_arrayAlign[] = { DT_CENTER, DT_LEFT, DT_RIGHT } ;
			static int c_arrayPrefix[] = { DT_NOPREFIX, 0, DT_HIDEPREFIX, DT_PREFIXONLY } ;
			static int c_arrayLine[] = { 0, DT_SINGLELINE, DT_WORDBREAK, DT_WORDBREAK|DT_NOFULLWIDTHCHARBREAK } ;
			static int c_arrayDirection[] = { 0, DT_RTLREADING } ;
			static int c_arrayExpandTabs[] = { 0, DT_EXPANDTABS } ;

			UINT unOverflow = c_arrayOverflow[TextOverflow()];
			UINT unVOverflow= c_arrayVOverflow[TextVOverflow()];
			UINT unVAlign   = c_arrayValign[TextVAlign()];
			UINT unAlign	= c_arrayAlign[TextAlign()];
			UINT unPrefix	= c_arrayPrefix[TextPrefix()];
			UINT unLine		= c_arrayLine[TextLine()];
			UINT unDirect	= c_arrayDirection[TextDirection()];
			UINT unExpandTab= c_arrayExpandTabs[TextExpandTabs()];

			return unOverflow | unVOverflow | unVAlign | unAlign | unPrefix | unLine | unDirect | unExpandTab;
		}

	private:
		void _defaultValue()
		{
			TextOverflow()		=	TEXT_OVERFLOW_CLIP;
			TextVOverflow()		=	TEXT_VOVERFLOW_AUTO;
			TextVAlign()		=	TEXT_ALIGN_CENTER;
			TextAlign()			=	TEXT_VALIGN_VCENTER;
			TextPrefix()		=	TEXT_PREFIX_NOTUSE;
			TextLine()			=	TEXT_LINE_AUTO;
			TextDirection()		=	TEXT_DIRECTION_LEFT_TO_RIGHT;
			TextExpandTabs()	=	TEXT_EXPAND_TABS_NOTUSE;
		}
	};
};